﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Be.Timvw.Framework.Domain.Ranges
{
    /// <summary>
    /// Specifications for the determination of when a range is in the range.
    /// </summary>
    [TestClass]
    public class WhenDeterminingIfRangeIsIncludedInRange
    {
        /// <summary>
        /// Should return true when tested period is in the period.
        /// </summary>
        [TestMethod]
        public void ShouldReturnTrueWhenTestedRangeIsSubRange()
        {
            Range<DateTime> dateTimeRange = RangeFactory.GetRangeForDaysFromFirstJanuary2000(10);
            Range<DateTime> includedDateTimeRange = new Range<DateTime>(dateTimeRange.Begin.AddDays(1), dateTimeRange.End.AddDays(-1));

            Assert.IsTrue(dateTimeRange.Includes(includedDateTimeRange));
        }

        /// <summary>
        /// Should return false when tested period begins before the period.
        /// </summary>
        [TestMethod]
        public void ShouldReturnFalseWhenRangeDoesNotIncludeBegin()
        {
            Range<DateTime> dateTimeRange = RangeFactory.GetRangeForDaysFromFirstJanuary2000(10);
            Range<DateTime> notIncludedDateTimeRange = new Range<DateTime>(dateTimeRange.Begin.AddDays(-1), dateTimeRange.End);

            Assert.IsFalse(dateTimeRange.Includes(notIncludedDateTimeRange));
        }

        /// <summary>
        /// Should return false when tested period ends after the period.
        /// </summary>
        [TestMethod]
        public void ShouldReturnFalseWhenRangeDoesNotIncludeEnd()
        {
            Range<DateTime> dateTimeRange = RangeFactory.GetRangeForDaysFromFirstJanuary2000(10);
            Range<DateTime> notIncludedDateTimeRange = new Range<DateTime>(dateTimeRange.Begin, dateTimeRange.End.AddDays(1));

            Assert.IsFalse(dateTimeRange.Includes(notIncludedDateTimeRange));
        }
    }
}